<?php
abstract class AbsPackage {
	protected $ext;
	
	abstract public function compress($in = '');
	abstract public function uncompress($in = '');
	abstract public function fcompress($in = null, $out = './');
	abstract public function funcompress($in = null, $out = './');
	
	protected function formatCompressOut($in = null, $out = './', $compress = true) {
		$ret = '';
		if(is_file($out)) {
			$ret = $out;
		} elseif(is_dir($out)) {
			$basename = basename($in, $this->ext);
			$realpath = realpath($out);
			if(false === $realpath) $realpath = './';
			$ret = rtrim($realpath, '/') . '/' . $basename . ($compress ? $this->ext : '');
		}
		
		return $ret;
	}
}
?>